<!DOCTYPE HTML>
<html lang="zh-CN">


<head>
    <meta charset="utf-8">
    <meta name="keywords" content="FFmpeg笔记(一), jiodg45的博客">
    <meta name="description" content="">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <meta name="renderer" content="webkit|ie-stand|ie-comp">
    <meta name="mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <!-- Global site tag (gtag.js) - Google Analytics -->


    <title>FFmpeg笔记(一) | jiodg45的博客</title>
    <link rel="icon" type="image/png" href="/jiodg45/favicon.png">

    <link rel="stylesheet" type="text/css" href="/jiodg45/libs/awesome/css/all.css">
    <link rel="stylesheet" type="text/css" href="/jiodg45/libs/materialize/materialize.min.css">
    <link rel="stylesheet" type="text/css" href="/jiodg45/libs/aos/aos.css">
    <link rel="stylesheet" type="text/css" href="/jiodg45/libs/animate/animate.min.css">
    <link rel="stylesheet" type="text/css" href="/jiodg45/libs/lightGallery/css/lightgallery.min.css">
    <link rel="stylesheet" type="text/css" href="/jiodg45/css/matery.css">
    <link rel="stylesheet" type="text/css" href="/jiodg45/css/my.css">

    <script src="/jiodg45/libs/jquery/jquery.min.js"></script>

<meta name="generator" content="Hexo 5.4.0">
<style>.github-emoji { position: relative; display: inline-block; width: 1.2em; min-height: 1.2em; overflow: hidden; vertical-align: top; color: transparent; }  .github-emoji > span { position: relative; z-index: 10; }  .github-emoji img, .github-emoji .fancybox { margin: 0 !important; padding: 0 !important; border: none !important; outline: none !important; text-decoration: none !important; user-select: none !important; cursor: auto !important; }  .github-emoji img { height: 1.2em !important; width: 1.2em !important; position: absolute !important; left: 50% !important; top: 50% !important; transform: translate(-50%, -50%) !important; user-select: none !important; cursor: auto !important; } .github-emoji-fallback { color: inherit; } .github-emoji-fallback img { opacity: 0 !important; }</style>
</head>




<body>
    <header class="navbar-fixed">
    <nav id="headNav" class="bg-color nav-transparent">
        <div id="navContainer" class="nav-wrapper container">
            <div class="brand-logo">
                <a href="/jiodg45/" class="waves-effect waves-light">
                    
                    <img src="/jiodg45/medias/logo.png" class="logo-img" alt="LOGO">
                    
                    <span class="logo-span">jiodg45的博客</span>
                </a>
            </div>
            

<a href="#" data-target="mobile-nav" class="sidenav-trigger button-collapse"><i class="fas fa-bars"></i></a>
<ul class="right nav-menu">
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/jiodg45/" class="waves-effect waves-light">
      
      <i class="fas fa-home" style="zoom: 0.6;"></i>
      
      <span>首页</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/jiodg45/tags" class="waves-effect waves-light">
      
      <i class="fas fa-tags" style="zoom: 0.6;"></i>
      
      <span>标签</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/jiodg45/categories" class="waves-effect waves-light">
      
      <i class="fas fa-bookmark" style="zoom: 0.6;"></i>
      
      <span>分类</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/jiodg45/archives" class="waves-effect waves-light">
      
      <i class="fas fa-archive" style="zoom: 0.6;"></i>
      
      <span>归档</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/jiodg45/about" class="waves-effect waves-light">
      
      <i class="fas fa-user-circle" style="zoom: 0.6;"></i>
      
      <span>关于</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/jiodg45/contact" class="waves-effect waves-light">
      
      <i class="fas fa-comments" style="zoom: 0.6;"></i>
      
      <span>留言板</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/jiodg45/friends" class="waves-effect waves-light">
      
      <i class="fas fa-address-book" style="zoom: 0.6;"></i>
      
      <span>友情链接</span>
    </a>
    
  </li>
  
  <li>
    <a href="#searchModal" class="modal-trigger waves-effect waves-light">
      <i id="searchIcon" class="fas fa-search" title="搜索" style="zoom: 0.85;"></i>
    </a>
  </li>
</ul>


<div id="mobile-nav" class="side-nav sidenav">

    <div class="mobile-head bg-color">
        
        <img src="/jiodg45/medias/logo.png" class="logo-img circle responsive-img">
        
        <div class="logo-name">jiodg45的博客</div>
        <div class="logo-desc">
            
            Never really desperate, only the lost of the soul.
            
        </div>
    </div>

    

    <ul class="menu-list mobile-menu-list">
        
        <li class="m-nav-item">
	  
		<a href="/jiodg45/" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-home"></i>
			
			首页
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/jiodg45/tags" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-tags"></i>
			
			标签
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/jiodg45/categories" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-bookmark"></i>
			
			分类
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/jiodg45/archives" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-archive"></i>
			
			归档
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/jiodg45/about" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-user-circle"></i>
			
			关于
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/jiodg45/contact" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-comments"></i>
			
			留言板
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/jiodg45/friends" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-address-book"></i>
			
			友情链接
		</a>
          
        </li>
        
        
        <li><div class="divider"></div></li>
        <li>
            <a href="https://github.com/blinkfox/hexo-theme-matery" class="waves-effect waves-light" target="_blank">
                <i class="fab fa-github-square fa-fw"></i>Fork Me
            </a>
        </li>
        
    </ul>
</div>


        </div>

        
            <style>
    .nav-transparent .github-corner {
        display: none !important;
    }

    .github-corner {
        position: absolute;
        z-index: 10;
        top: 0;
        right: 0;
        border: 0;
        transform: scale(1.1);
    }

    .github-corner svg {
        color: #0f9d58;
        fill: #fff;
        height: 64px;
        width: 64px;
    }

    .github-corner:hover .octo-arm {
        animation: a 0.56s ease-in-out;
    }

    .github-corner .octo-arm {
        animation: none;
    }

    @keyframes a {
        0%,
        to {
            transform: rotate(0);
        }
        20%,
        60% {
            transform: rotate(-25deg);
        }
        40%,
        80% {
            transform: rotate(10deg);
        }
    }
</style>

<a href="https://github.com/blinkfox/hexo-theme-matery" class="github-corner tooltipped hide-on-med-and-down" target="_blank"
   data-tooltip="Fork Me" data-position="left" data-delay="50">
    <svg viewBox="0 0 250 250" aria-hidden="true">
        <path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path>
        <path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2"
              fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path>
        <path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z"
              fill="currentColor" class="octo-body"></path>
    </svg>
</a>
        
    </nav>

</header>

    



<div class="bg-cover pd-header post-cover" style="background-image: url('/jiodg45/medias/featureimages/8.jpg')">
    <div class="container" style="right: 0px;left: 0px;">
        <div class="row">
            <div class="col s12 m12 l12">
                <div class="brand">
                    <h1 class="description center-align post-title">FFmpeg笔记(一)</h1>
                </div>
            </div>
        </div>
    </div>
</div>




<main class="post-container content">

    
    <link rel="stylesheet" href="/jiodg45/libs/tocbot/tocbot.css">
<style>
    #articleContent h1::before,
    #articleContent h2::before,
    #articleContent h3::before,
    #articleContent h4::before,
    #articleContent h5::before,
    #articleContent h6::before {
        display: block;
        content: " ";
        height: 100px;
        margin-top: -100px;
        visibility: hidden;
    }

    #articleContent :focus {
        outline: none;
    }

    .toc-fixed {
        position: fixed;
        top: 64px;
    }

    .toc-widget {
        width: 345px;
        padding-left: 20px;
    }

    .toc-widget .toc-title {
        padding: 35px 0 15px 17px;
        font-size: 1.5rem;
        font-weight: bold;
        line-height: 1.5rem;
    }

    .toc-widget ol {
        padding: 0;
        list-style: none;
    }

    #toc-content {
        padding-bottom: 30px;
        overflow: auto;
    }

    #toc-content ol {
        padding-left: 10px;
    }

    #toc-content ol li {
        padding-left: 10px;
    }

    #toc-content .toc-link:hover {
        color: #42b983;
        font-weight: 700;
        text-decoration: underline;
    }

    #toc-content .toc-link::before {
        background-color: transparent;
        max-height: 25px;

        position: absolute;
        right: 23.5vw;
        display: block;
    }

    #toc-content .is-active-link {
        color: #42b983;
    }

    #floating-toc-btn {
        position: fixed;
        right: 15px;
        bottom: 76px;
        padding-top: 15px;
        margin-bottom: 0;
        z-index: 998;
    }

    #floating-toc-btn .btn-floating {
        width: 48px;
        height: 48px;
    }

    #floating-toc-btn .btn-floating i {
        line-height: 48px;
        font-size: 1.4rem;
    }
</style>
<div class="row">
    <div id="main-content" class="col s12 m12 l9">
        <!-- 文章内容详情 -->
<div id="artDetail">
    <div class="card">
        <div class="card-content article-info">
            <div class="row tag-cate">
                <div class="col s7">
                    
                    <div class="article-tag">
                        
                            <a href="/jiodg45/tags/audio/">
                                <span class="chip bg-color">audio</span>
                            </a>
                        
                            <a href="/jiodg45/tags/ffmpeg/">
                                <span class="chip bg-color">ffmpeg</span>
                            </a>
                        
                    </div>
                    
                </div>
                <div class="col s5 right-align">
                    
                    <div class="post-cate">
                        <i class="fas fa-bookmark fa-fw icon-category"></i>
                        
                            <a href="/jiodg45/categories/ffmpeg/" class="post-category">
                                ffmpeg
                            </a>
                        
                    </div>
                    
                </div>
            </div>

            <div class="post-info">
                
                <div class="post-date info-break-policy">
                    <i class="far fa-calendar-minus fa-fw"></i>发布日期:&nbsp;&nbsp;
                    2021-03-11
                </div>
                

                

                

                

                
            </div>
        </div>
        <hr class="clearfix">

        

        

        <div class="card-content article-card-content">
            <div id="articleContent">
                <h2 id="FFmpeg简介"><a href="#FFmpeg简介" class="headerlink" title="FFmpeg简介"></a>FFmpeg简介</h2><p>ffmpeg是一个非常快的视频/音频转换器，其也可以现场抓取音频/视频源，并在任意采样率、尺寸之间调整视频，以及提供多种高品质的滤镜系统。</p>
<h2 id="FFmpeg涉及的基本概念"><a href="#FFmpeg涉及的基本概念" class="headerlink" title="FFmpeg涉及的基本概念"></a>FFmpeg涉及的基本概念</h2><ol>
<li>分辨率: 分辨率可以分为显示分辨率与图像分辨率. </li>
</ol>
<p>显示分辨率是指屏幕显示器的分辨率,是屏幕的像素(每一个像素 pixel是由多个颜色单元subPixel组成)密度决定的在单位英寸内像素越多,<br>硬件所能控制的颜色点位越多,屏幕的显示的画面就会越精细。在手机参数一栏都会标有屏幕分辨率是多少。目前手机上常见的分辨率有720p，<br>1080p以及2K,以720p、1080p、2k为例：720p表示的是1280*720的分辨率；1080p表示的是1920*1080的分辨率；2K则表示的是<br>2560*1440的分辨率（这里需要说明的是，”*”前面的数字指的是屏幕长度像素个数，后面的数字指的是屏幕宽度像素个数，而且比例对应了以<br>前16:9的屏幕比例. 进入“全面屏”时代，屏幕比例基本上改成了18:9的比例，进而衍生出了720p+，1080p+，2K+等分辨率）</p>
<p>图像分辨率就是只图像长宽乘积的大小,横向和纵向的像素(pixel)的数量</p>
<ol start="2">
<li>屏幕像素密度: ppi(Pixels per Inch)</li>
</ol>
<p>所表示的是每英寸所拥有的像素数量。因此ppi数值越高，即代表显示屏能够以越高的密度显示图像。以长宽方向的像素个数为直角三角形的两边，通过勾股定义就可以计算出对角线上像素的个数，然后用这个数值除以屏幕对角(左下顶点到右上顶点的)距离就是 ppi了.</p>
<p>因此屏幕显示异常清晰、锐利。对于目前的AMOLED屏幕，子像素排列方式有别于LCD的RGB排列方式，AMOLED屏幕的子像素排列方式基本上都是采用PenTile排列， PenTile排列技术最关键的地方就是利用不规则的子像素排列，以更少的子像素点代替更多的子像素点。在同尺寸同分辨率的情况下采用PenTile排列的屏幕像素密度实际只有RGB排列的屏幕像素密度的80%，所以就有了“无2K，不A屏”的说<br>更多请参考: <a target="_blank" rel="noopener" href="http://www.360doc.com/content/19/0908/03/40520079_859759183.shtml">http://www.360doc.com/content/19/0908/03/40520079_859759183.shtml</a></p>
<ol start="3">
<li>Dpi: 基于上文的 sub pixel物理的排列格式,人们就发明了新的计算方式<a target="_blank" rel="noopener" href="http://www.360doc.com/content/17/0107/17/14106735_620766397.shtml">DPI</a></li>
</ol>
<p>Dpi表示分辨率,指每英寸长度上的点数, DPI又可以细分为水平分辨率和垂直分辨率,例如一张1英*1英寸的图片,如果它的水平分辨率是100 dpi,垂直分辨率是50 dpi,那么就是说,它水平每英寸分成100小段,垂直每英寸分成50小段,就像米尺上的一格格那样.这张图总共有100<em>50=5000个格子， 这张图片共有5000像素.由于它的水平分辨率和垂直分辨率不相等,所以每个像素是一个*<em>微小的长方形.</em></em></p>
<ol start="4">
<li>帧速率: FPS(Frames PerSecond)的缩写——帧/秒</li>
</ol>
<p>它指每秒钟界面屏幕刷新的次数,一般帧率25以上人眼就很难发觉,但如果是告诉流动的画质还是会有卡顿的感觉. 一般手机内的应用帧率都控制在60以上,这样能更好的保证界面的流畅度.影像FPS的物理因数主要是显卡, 如果FPS值过低可以尝试通过调节一些游戏或者电脑参数来缓解如：降低游戏分辨率、开启垂直同步等等。</p>
<ol start="5">
<li>脉冲编码调制:(Pulse Code Modulation,PCM))</li>
</ol>
<p>就是把一个时间连续，取值连续的模拟信号变换成时间离散，取值离散的数字信号后在信道中传输。脉冲编码调制就是对模拟信号先抽样，再对样值幅度量化，编码的过程。它包含几个关键指标</p>
<p>a.抽样，就是对模拟信号进行周期性扫描，把时间上连续的信号变成时间上离散的信号<br>b.量化，就是把经过抽样得到的瞬时值将其幅度离散，即用一组规定的电平，把瞬时抽样值用最接近的电平值来表示,通常是用二进制表示.<br>c.量化误差：量化后的信号和抽样信号的差值。量化误差在接收端表现为噪声，称为量化噪声。 量化级数越多误差越小，相应的二进制码位数越多，要求传输速率越高，频带越宽。为使量化噪声尽可能小而所需码位数又不太多，通常采用非均匀量化的方法进行量化。 非均匀量化根据幅度的不同区间来确定量化间隔，幅度小的区间量化间隔取得小，幅度大的区间量化间隔取得. 一个模拟信号经过抽样量化后，得到已量化的脉冲幅度调制信号，它仅为有限个数值。这样就能完成将一个模拟信号周期内的数组以事件单位按顺序记录每个时刻的信号强弱值。</p>
<ol start="6">
<li>采样位深: </li>
</ol>
<p>基于上面的PCM调制解调的原理,上面最终取到信号强弱值存储大小和采样位深的大小有着密切的联系，常见的16bit（16比特），可以记录大概96分贝的动态范围,也就是说这个点的信号值用 16bit的内存空间来表示</p>
<ol start="7">
<li>采样率：<br>采样率（也称为采样速度或者采样频率）定义了每秒从连续信号中提取并组成离散信号的采样个数，它用赫兹（Hz）来表示。采样率是指将模拟信号转换成数字信号时的采样频率，也就是单位时间内采样多少点。一个采样点数据有多少个比特。我们人耳能听到的声音一般在20Hz~20KHz之间，根据奈奎斯特采样定理，采样频率fs大于信号中最高频率fmax的2倍时，采样之后的数字信号便能完整的反应真实信号。所以44.1KHz为常见的采样率。</li>
</ol>
<p>人的发音器官发出的声音频率大约是80<del>3400Hz，但人说话的信号平率通常为300</del>3000Hz，人们把这种频率范围的信号称为话音（speech）信号。</p>
<ol start="8">
<li>码流: Data Rate</li>
</ol>
<p>也叫码率是指在1秒钟内，通信端口在传输数据时高低电平变化的次数，也叫码率，单位时间内传送的数据越多，所包含的信息量也越多，是视频编码中画面质量控制中最重要的部分<br>一般情况下，DVD格式歌曲的码流为6~8M；VCD歌曲的码流约为1.5M。相同配置和同样网络环境下，DVD歌曲和VCD歌曲的并发流是不一样的。视频比特率与码流只是同一个问题两种叫法，比如一个MPEG2视频文件，一般不但包含视频信息还有音频信息，音频也有自己的比特率，这是音视信息复合在一起的文件，这个文件的码流是其音视码流的总和。</p>
<p>多码流:<br>多码流技术是通过在编码过程中同时产生多种不同码流及分辨率的流媒体数据，根据用户实际网络带宽条件为之自动分配相对最佳解码画质的解决方案。在实际网络直播应用中，由于位于不同网络位置的访问者所在网络环境存在差异，而仅以某种固定码流分辨率进行网络直播流媒体传送往往会导致网速较高的用户看到的画质仍不够清晰，网速较低的用户解码时间过长而使得画面不够流畅，为解决二者的矛盾使访问者浏览到尽可能看到兼顾清晰和流畅的直播内容，采用多码流技术成为了一个最简单最有效的办法。</p>
<p><strong>码率=采样率(hz) X 位深度(也叫量化精度,电频信号振幅的上下范围) X 声道(同时采集的输入源)</strong></p>
<p>文件大小=码率 x 时长(s) ,这里暂时省略了文件属性以及压缩编码后的数据,仅从原始文件的角度来分析</p>
<ol start="9">
<li><p>采样率: 也成为采样速度和采样频率，定义了每秒钟从连续信号中提取并组成离散信号的采样个数,用Hz表示,它记录了将模拟信号专程数字信号的采样频率，也就是单位事件内采样多少点,一个采样点就多个bi数据,  采样率 乘以每秒钟采样的个数就能得出它的码率</p>
</li>
<li><p>视频比特率<br>视频比特率是指每秒传送的比特(bit)数。单位为bps(Bit Per Second)，比特率越高，每秒传送数据就越多，画质就越清晰。声音中的比特率是指将模拟声音信号转换成数字声音信号后，单位时间内的二进制数据量，是间接衡量音频质量的一个指标。 视频中的比特率(码率)原理与声音中的相同，都是指由模拟信号转换为数字信号后，单位时间内的二进制数据量。</p>
</li>
<li><p>通道数</p>
</li>
</ol>
<p>即声音的通道的数目。常有单声道和立体声之分，单声道的声音只能使用一个喇叭发声（有的也处理成两个喇叭输出同一个声道的声音），立体声可以使两个喇叭都发声（一般左右声道有分工） ，更能感受到空间效果，当然还有更多的通道数。</p>
<ol start="12">
<li>通道</li>
</ol>
<p>通道条（channel strip）其实一个继承自模拟时代的概念，原本是指调音台上任一通道上所有处理元件，通常有话放、高低切、均衡、压缩等等， 除了调音台，设备商也推出了各种单通道（有时也有双通道供立体声输入使用）的通道条</p>
<ol start="13">
<li>mutxers 视音频复用器（Muxer）</li>
</ol>
<p>用于FFmpeg音视频复用,是将视频压缩数据（例如H.264）和音频压缩数据（例如AAC）合并到一个封装格式数据（例如MKV）中去。在这个过程中并不涉及到编码和解码。同样的还有复用器。</p>
<h2 id="FFmpeg中音视频编码格式"><a href="#FFmpeg中音视频编码格式" class="headerlink" title="FFmpeg中音视频编码格式"></a>FFmpeg中音视频编码格式</h2><ol>
<li><p>Mp3: 一种音频编码方式,利用 MPEG Audio Layer 3 的技术，将音乐以1:10 甚至 1:12 的压缩率，压缩成容量较小的文件</p>
</li>
<li><p>ACC: 高级音频编码技术，Advanced Audio Coding.</p>
</li>
</ol>
<p>AAC(高级音频编码技术，Advanced Audio Coding)是杜比实验室为音乐社区提供的技术。AAC可以支持多达48个音轨，15个低频（LFE）音轨，5.1多声道支持，更高的采样率（最高可达96kHz，音频CD为44.1kHz）和更高的采样精度（支持8bit、16bit、24bit、32bit，音频CD为16bit）以及有多种语言的兼容能力，更高的解码效率，一般来说，AAC可以在对比MP3文件缩小30%的前提下提供更好的音质。</p>
<p>AAC编码的主要扩展名有三种：<br>    .AAC - 使用MPEG-2 Audio Transport Stream（ADTS，参见MPEG-2）容器，区别于使用MPEG-4容器的MP4/M4A格式，属于传统的AAC编码（FAAC默认的封装，但FAAC亦可输出MPEG-4封装的AAC）<br>    .MP4 - 使用了MPEG-4 Part 14（第14部分）的简化版即3GPP Media Release 6 Basic（3gp6，参见3GP）进行封装的AAC编码（Nero AAC编码器仅能输出MPEG-4封装的AAC）；<br>    .M4A - 为了区别纯音频MP4文件和包含视频的MP4文件而由苹果（Apple）公司使用的扩展名，Apple iTunes对纯音频MP4文件采用了”.M4A”命名。M4A的本质和音频MP4相同，故音频MP4文件亦可直接更改扩展名为M4A</p>
<p>对比Mp3<br>比特率：AAC - 最高512kbps（双声道时）/MP3 - 32~320kbps<br>采样率：AAC - 最高96kHz / MP3 - 最高48kHz<br>声道数：AAC - （5.1）六声道 / MP3 - 两声道<br>采样精度：AAC - 最高32bit / MP3 - 最高16bit</p>
<ol start="3">
<li>H.264，视频编码格式</li>
</ol>
<p>是MPEG-4第十部分，是由ITU-T视频编码专家组（VCEG）和ISO/IEC动态图像专家组（MPEG）联合组成的联合视频组（JVT，Joint Video Team）提出的高度压缩数字视频编解码器标准。</p>
<p>H264标准各主要部分有Access Unit delimiter（访问单元分割符），SEI（附加增强信息），primary coded picture（基本图像编码），Redundant Coded Picture（冗余图像编码）。还有Instantaneous Decoding Refresh（IDR，即时解码刷新）、Hypothetical Reference Decoder（HRD，假想参考解码）、Hypothetical Stream Scheduler（HSS，假想码流调度器）。</p>
<p>同H.263等标准的特率效率相比，能够平均节省大于50%的码率。技术上，它集中了以往标准的优点，并吸收了标准制定中积累的经验.<br>帧内预测编码,整数变换,帧间预测编码,多帧预测,整数变换,量化,熵编码 … </p>
<ol start="4">
<li>YUV: 颜色编码格式<br>YUV是编译true-color颜色空间（color space）的种类，Y’UV, YUV, YCbCr，YPbPr等专有名词都可以称为YUV，彼此有重叠。“Y”表示明亮度（Luminance或Luma），也就是灰阶值，“U”和“V”表示的则是色度（Chrominance或Chroma），作用是描述影像色彩及饱和度，用于指定像素的颜色。</li>
</ol>
<p>为节省带宽起见，大多数YUV格式平均使用的每像素位数都少于24位。主要的抽样（subsample）格式有YCbCr4:2:0、YCbCr4:2:2、YCbCr4:1:1和YCbCr4:4:4。YUV的表示法称为A:B:C表示法：</p>
<p>4:4:4表示完全取样。<br>4:2:2表示2:1的水平取样，垂直完全采样。<br>4:2:0表示2:1的水平取样，垂直2：1采样。<br>4:1:1表示4:1的水平取样，垂直完全采样。<br>图解: </p>
<p><img src="http://assets.processon.com/chart_image/604cf6f51e0853179f5991d2.png" alt="yuv"></p>
<p>每个像素占2*4个格子,8bit. 其中亮度每个格子都有值。Cb和Cr根据不同的格式进行取样, 上面的方块非常的有规律,除去前面的4, 按照从左到右从上到下的顺序数格子就能清楚的明白了什么是垂直扫描，什么是水平扫描了,扫描间隔了。</p>
<ol start="4">
<li>容器格式</li>
</ol>
<p>视频文件本身其实是一个容器（container），里面包括了视频和音频，也可能有字幕等其他内容,一般是通过<code>.</code>号加后缀组成。我们电脑上和手机上的任何文件都是以容器存储的。</p>
<h2 id="FFmpeg基础帮助命令介绍"><a href="#FFmpeg基础帮助命令介绍" class="headerlink" title="FFmpeg基础帮助命令介绍"></a>FFmpeg基础帮助命令介绍</h2><ol>
<li>下载github源码<code>https://github.com/FFmpeg/FFmpeg.git</code>,本地安装make,然后参照<code>install.md</code>编译ffmpeg,然后在终端之行<code>ffmpeg</code></li>
</ol>
<figure class="highlight shell"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">qxq4633@LSCN897187 FFmpeg % ffmpeg</span><br><span class="line">ffmpeg version N-98900-gccc7120ee7 Copyright (c) 2000-2020 the FFmpeg developers</span><br><span class="line">  built with Apple clang version 11.0.3 (clang-1103.0.32.62)</span><br><span class="line">  configuration: --disable-x86asm</span><br><span class="line">  libavutil      56. 58.100 / 56. 58.100</span><br><span class="line">  libavcodec     58.101.100 / 58.101.100</span><br><span class="line">  libavformat    58. 51.101 / 58. 51.101</span><br><span class="line">  libavdevice    58. 11.101 / 58. 11.101</span><br><span class="line">  libavfilter     7. 87.100 /  7. 87.100</span><br><span class="line">  libswscale      5.  8.100 /  5.  8.100</span><br><span class="line">  libswresample   3.  8.100 /  3.  8.100</span><br><span class="line">Hyper fast Audio and Video encoder</span><br><span class="line">usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...</span><br></pre></td></tr></tbody></table></figure>

<ol start="2">
<li><p>它的语法格式主要分为三大块<br><code>ffmpeg [全局选项] [输入文件选项及输入文件路径] [输入文件选项及输出文件路径]</code>也可以细分成5块</p>
</li>
<li><p>由于命令比较多,使用<code>ffmpeg -h</code>查看一些基础的用法</p>
</li>
</ol>
<figure class="highlight plain"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br></pre></td><td class="code"><pre><span class="line">qxq4633@LSCN897187 FFmpeg % ffmpeg -h</span><br><span class="line">Getting help:</span><br><span class="line">    -h      -- print basic options </span><br><span class="line">    -h long -- print more options  //更加详细的帮助文档</span><br><span class="line">    -h full -- print all options (including all format and codec specific options, very long) //查看全部的帮助文档</span><br><span class="line">    -h type=name -- print all options for the named decoder/encoder/demuxer/muxer/filter/bsf/protocol //查编解码器多路调制的命令选项详情</span><br><span class="line">    See man ffmpeg for detailed description of the options.</span><br><span class="line"></span><br><span class="line">Print help / information / capabilities:</span><br><span class="line">-L                  show license</span><br><span class="line">-h topic            show help</span><br><span class="line">-? topic            show help</span><br><span class="line">-help topic         show help</span><br><span class="line">--help topic        show help</span><br><span class="line">-version            show version</span><br><span class="line">-buildconf          show build configuration</span><br><span class="line">-formats            show available formats  //查看ffmpeg所支持的容器格式</span><br><span class="line">-muxers             show available muxers   //查看所有的音视频复用器</span><br><span class="line">-demuxers           show available demuxers //查看所有的解音视频复用器</span><br><span class="line">-devices            show available devices</span><br><span class="line">-codecs             show available codecs   //查看所有的编解格式</span><br><span class="line">-decoders           show available decoders</span><br><span class="line">-encoders           show available encoders</span><br><span class="line">-bsfs               show available bit stream filters  //显示所有可用的比特流过滤器</span><br><span class="line">-protocols          show available protocols</span><br><span class="line">-filters            show available filters  //显示所有可用的过滤器 </span><br><span class="line">-pix_fmts           show available pixel formats //显示所有支持的pixel fomart,如YUV，RGBA</span><br><span class="line">-layouts            show standard channel layouts</span><br><span class="line">-sample_fmts        show available audio sample formats</span><br><span class="line">-colors             show available color names</span><br><span class="line">-sources device     list sources of the input device</span><br><span class="line">-sinks device       list sinks of the output device</span><br><span class="line">-hwaccels           show available HW acceleration methods</span><br></pre></td></tr></tbody></table></figure>

<ol start="4">
<li>常用的选项参数介绍</li>
</ol>
<figure class="highlight plain"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br></pre></td><td class="code"><pre><span class="line">Global options (affect whole program instead of just one file):</span><br><span class="line">-y                  overwrite output files  //覆盖输出文件，即如果 output.wmv 文件已经存在的话，不经提示就覆盖掉 </span><br><span class="line">-n                  never overwrite output files</span><br><span class="line">-vol volume         change audio volume (256=normal)</span><br><span class="line"></span><br><span class="line">Per-file main options:</span><br><span class="line">-f fmt              force format</span><br><span class="line">-c codec            codec name  指定编码器</span><br><span class="line">-pre preset         preset name 指定输出的视频质量，会影响文件的生成速度，有以下几个可用的值 ultrafast, superfast, veryfast, faster, fast, medium, slow, slower, veryslow。</span><br><span class="line">-map_metadata outfile[,metadata]:infile[,metadata]  set metadata information of outfile from infile</span><br><span class="line">-t duration         record or transcode "duration" seconds of audio/video   //设置纪录时间 hh:mm:ss[.xxx]格式的记录时间也支持 </span><br><span class="line">-to time_stop       record or transcode stop time</span><br><span class="line">-fs limit_size      set the limit file size in bytes</span><br><span class="line">-ss time_off        set the start time offset</span><br><span class="line">...</span><br><span class="line"></span><br><span class="line">Video options:</span><br><span class="line">-vframes number     set the number of video frames to output</span><br><span class="line">-r rate             set frame rate (Hz value, fraction or abbreviation)</span><br><span class="line">-s size             set frame size (WxH or abbreviation) ,如368x208 输出的分辨率为368x208，注意片源一定要是16:9的不然会变形 </span><br><span class="line">-aspect aspect      set aspect ratio (4:3, 16:9 or 1.3333, 1.7777)</span><br><span class="line">-bits_per_raw_sample number  set the number of bits per raw sample</span><br><span class="line">-vn                 disable video //用于分离视频</span><br><span class="line">-ab bitrate         audio bitrate (please use -b:a)</span><br><span class="line">-b bitrate          video bitrate (please use -b:v)</span><br><span class="line">...</span><br><span class="line"></span><br><span class="line">Audio options:</span><br><span class="line">-aframes number     set the number of audio frames to output //输出多少帧</span><br><span class="line">-aq quality         set audio quality (codec-specific)</span><br><span class="line">-ar rate            set audio sampling rate (in Hz) //设置采样频率</span><br><span class="line">-ac channels        set number of audio channels //设置声道数， 1，2</span><br><span class="line">-an                 disable audio //用于分离音频,搭配 -c copy,直接将视频拷贝容器</span><br><span class="line">-acodec codec       force audio codec ('copy' to copy stream)</span><br><span class="line">-vol volume         change audio volume (256=normal）  </span><br></pre></td></tr></tbody></table></figure>

<h2 id="使用FFmpeg命令操作音视频"><a href="#使用FFmpeg命令操作音视频" class="headerlink" title="使用FFmpeg命令操作音视频"></a>使用FFmpeg命令操作音视频</h2><ol>
<li>查看文件信息 <code>ffmpeg -i 64k_output.mov</code>, 在Mac上可以通过quickTime,MediaInfo查看</li>
</ol>
<figure class="highlight plain"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">qxq4633@LSCN897187 ffmpegdemo % ffmpeg -i 64k_output.mov </span><br><span class="line">...</span><br><span class="line">Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '64k_output.mov':</span><br><span class="line">  Metadata:</span><br><span class="line">    major_brand     : qt  </span><br><span class="line">    minor_version   : 512</span><br><span class="line">    compatible_brands: qt  </span><br><span class="line">    encoder         : Lavf58.51.101</span><br><span class="line">  Duration: 00:00:26.63, start: 0.000000, bitrate: 1499 kb/s</span><br><span class="line">    Stream #0:0: Video: mpeg4 (Simple Profile) (mp4v / 0x7634706D), yuv420p, 766x1334 [SAR 1:1 DAR 383:667], 1497 kb/s, 60 fps, 60 tbr, 15360 tbn, 60 tbc (default)</span><br><span class="line">    Metadata:</span><br><span class="line">      handler_name    : Core Media Video</span><br><span class="line">      encoder         : Lavc58.101.100 mpeg4</span><br></pre></td></tr></tbody></table></figure>

<ol start="2">
<li>转换视频编码格式</li>
</ol>
<p>如转换成<code>H.264</code>格式 <code>ffmpegdemo % ffmpeg -i input.mov -c:v h264_videotoolbox 264_ouput.mov</code>,<br>可以通过<code>ffmpeg -encoders</code>来查看编码器名称<br>如转换成<code>H.264</code>格式 <code>ffmpegdemo % ffmpeg -i input.mov -c:v hevc_videotoolbox 265_ouput.mov</code>, </p>
<ol start="3">
<li>转换容器格式 <code>ffmpeg -i input.mp4 -c copy output.webm</code></li>
</ol>
<p>在前面的命令中<code>-c</code>主要是用来之行编码器的名字的，这里由于不需要编码,使用<code>-c copy</code></p>
<figure class="highlight plain"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">-c codec            codec name  //为了区分音视频编码,命令选项参数后加上 :v 或者 :a 分别表示音视频</span><br></pre></td></tr></tbody></table></figure>

<ol start="4">
<li>调整视频的每帧的数量 </li>
</ol>
<figure class="highlight plain"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ffmpeg -i input.mov -r 20 output.mov</span><br></pre></td></tr></tbody></table></figure>

<ol start="5">
<li>调整码率,一般用来减少视频的体积大小</li>
</ol>
<figure class="highlight plain"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ffmpeg -i  input.mov -b 1500K output.mov</span><br></pre></td></tr></tbody></table></figure>

<ol start="6">
<li>调整图片的分辨率(transsizing)</li>
</ol>
<figure class="highlight plain"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ffmpeg -i input.mov -vf scale=480:-1 output.mov</span><br></pre></td></tr></tbody></table></figure>

<p>可以使用<code>ffmpeg -h filter=scale</code>来查看sacle相关帮助命令,不过这里的描述并不是很具体,在<code>FFmpeg/doc/filters.texi</code>文件中找到了关于<code>scale</code>的详细描述</p>
<p>我的原始文件为<code>766x1334</code>,执行此命令后表示为<code>480x836</code>, 关于后面的<code>-1</code>选项与这段文字有关</p>
<figure class="highlight plain"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">One useful instance of this option is that when you know a specific device's</span><br><span class="line">maximum allowed resolution, you can use this to limit the output video to</span><br><span class="line">that, while retaining the aspect ratio. For example, device A allows</span><br><span class="line">1280x720 playback, and your video is 1920x800. Using this option (set it to</span><br><span class="line">decrease) and specifying 1280x720 to the command line makes the output</span><br><span class="line">1280x533.</span><br><span class="line"></span><br><span class="line">Please note that this is a different thing than specifying -1 for @option{w}</span><br><span class="line">or @option{h}, you still need to specify the output resolution for this option</span><br><span class="line">to work.</span><br></pre></td></tr></tbody></table></figure>
<p>大致意思就是由于我们事先不知道设备支持的最大分辨率，使用此参数可以支持缩小视频以适配系统设备分辨率。</p>
<p>关于scale的选项参数更多请参考<code>FFmpeg/doc/filters.texi</code>文件,<br>常用的选项还有<br>指定宽高: <code>scale=w=200:h=100 ，  scale=200:100 ，scale=200x100</code><br>指定一个大小的名字: <code>scale=qcif， scale=size=qcif</code><br>放大两倍: <code>scale=w=2*iw:h=2*ih, scale=2*in_w:2*in_h</code><br>缩小一半: <code>scale=w=iw/2:h=ih/2</code><br>增大宽,高保持一样: <code>scale=3/2*iw:ow</code>,同理<code>scale=3/2*iw:ow</code><br>将宽度增加到最大500像素: <code>scale=w='min(500\, iw*3/2):h=-1'</code></p>
<p>上面语法中使用的字符在<code>filters.texi</code>均有定义,通过<code>@item</code>定义的<br><code>i</code>表示<code>input</code>输入文件的意思,其它的依次类推<br><code>qcif</code>代表某个写好的尺寸,在<code>utils.texi</code>文件中有详细的定义,常用的如下</p>
<figure class="highlight plain"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">@item sqcif</span><br><span class="line">128x96</span><br><span class="line">...</span><br><span class="line">@item hd720</span><br><span class="line">1280x720</span><br><span class="line">@item hd1080</span><br><span class="line">1920x1080</span><br></pre></td></tr></tbody></table></figure>

<ol start="7">
<li>提取音频</li>
</ol>
<figure class="highlight plain"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ffmpeg -i input.mov -vn -c:a copy output.aac</span><br></pre></td></tr></tbody></table></figure>
<p>命令描述</p>
<figure class="highlight plain"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">-vn                 disable video</span><br><span class="line">-an                 disable audio</span><br></pre></td></tr></tbody></table></figure>
<p>vn,an分别表示为 video no, audio no,这样可以方便记忆</p>
<ol start="8">
<li>为视频文件添加音轨</li>
</ol>
<figure class="highlight plain"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ffmpeg -i input.aac -i input.mp4 output.mp4</span><br></pre></td></tr></tbody></table></figure>

<ol start="9">
<li>截图</li>
</ol>
<figure class="highlight plain"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">ffmpeg \</span><br><span class="line">-y \               //overwrite output files</span><br><span class="line">-i input.mov \     </span><br><span class="line">-ss 00:01.00 -t 00:00:01 \</span><br><span class="line">output_%3d.jpg</span><br></pre></td></tr></tbody></table></figure>

<p>涉及的命令</p>
<figure class="highlight plain"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">-ss time_off        set the start time offset </span><br><span class="line">-t duration         record or transcode "duration" seconds of audio/video</span><br><span class="line">-timecode hh:mm:ss[:;.]ff  set initial TimeCode value. //也可以指定time的格式</span><br></pre></td></tr></tbody></table></figure>


<ol start="10">
<li>设置图片质量</li>
</ol>
<figure class="highlight plain"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">ffmpeg \</span><br><span class="line">-ss 01:23:45 \</span><br><span class="line">-i input \</span><br><span class="line">-vframes \1 -q:v 2 \ </span><br><span class="line">output.jpg</span><br></pre></td></tr></tbody></table></figure>

<p>相关命令</p>
<figure class="highlight plain"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">-vframes number     set the number of video frames to output </span><br></pre></td></tr></tbody></table></figure>
<p>关于<code>q:v</code>命令在<code>encoders.texi</code>中可以找到描述，q为quality的首字母， v推测为VBR的首字母。格式为<code>[options]:[options  specifier] [option value]</code></p>
<figure class="highlight plain"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">Set maximum constant quality (VBR) encoding with @command{ffmpeg}:</span><br><span class="line">@example</span><br><span class="line">ffmpeg -i INPUT -codec:v libtheora -q:v 10 OUTPUT.ogg</span><br></pre></td></tr></tbody></table></figure>

<ol start="11">
<li>裁切视频的指定区域</li>
</ol>
<figure class="highlight plain"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ffmpeg -i input.mov -strict -2 -vf crop=20:20:0:20 output.mov</span><br></pre></td></tr></tbody></table></figure>

<p>通过<code>ffmpeg -h filter=crop</code>文档介绍,格式<code>crop=width:height:x:y</code>表示宽高(20,20),裁剪区域的左上角坐标(0,20)。<br>strict没有找到相关的帮助文档,代码中有一些断言要求使用<code>strict -1</code>或<code>-2</code>,推测应该是某种约束</p>
<h2 id="参考链接"><a href="#参考链接" class="headerlink" title="参考链接"></a>参考链接</h2><p><a target="_blank" rel="noopener" href="https://baike.baidu.com/item/PCM/1568054?fr=aladdin">百度百科-PCM脉冲编码调制</a><br><a target="_blank" rel="noopener" href="https://baike.baidu.com/item/%E9%87%87%E6%A0%B7%E9%A2%91%E7%8E%87?fromtitle=%E9%87%87%E6%A0%B7%E7%8E%87&amp;fromid=972301">百度百科-采样率</a><br><a target="_blank" rel="noopener" href="https://baike.baidu.com/item/%E6%95%B0%E6%8D%AE%E5%B8%A7/10571824?fr=aladdin">百度百科-帧</a><br><a target="_blank" rel="noopener" href="https://baike.baidu.com/item/ACC/8537680?fr=aladdin">百度百科-ACC</a><br><a target="_blank" rel="noopener" href="https://baike.baidu.com/item/mp3/23904">百度百科-Mp3</a><br><a target="_blank" rel="noopener" href="https://www.cnblogs.com/TaigaCon/p/9893847.html">ffmpeg音频样本</a><br><a target="_blank" rel="noopener" href="https://blog.csdn.net/u014162133/article/details/111936900?utm_medium=distribute.pc_relevant.none-task-blog-baidujs_title-12&amp;spm=1001.2101.3001.4242">音频相关知识：声道、采样率、采样位数、样本格式、比特率</a><br><a target="_blank" rel="noopener" href="http://www.ruanyifeng.com/blog/2020/01/ffmpeg.html">FFmpeg 视频处理入门教程</a><br><a target="_blank" rel="noopener" href="http://xdsnet.github.io/other-doc-cn-ffmpeg/index.html">FFmpeg帮助文档翻译</a><br><a target="_blank" rel="noopener" href="https://www.zhihu.com/question/281173490/answer/420381465">知乎-音频通道</a><br><a target="_blank" rel="noopener" href="https://blog.csdn.net/qq_19923217/article/details/83348095">H264编码协议详解</a><br><a target="_blank" rel="noopener" href="http://slhck.info/ffmpeg-encoding-course/#/19">YUV-PIXEL FORMATS</a><br><a target="_blank" rel="noopener" href="https://github.com/FFmpeg/FFmpeg.git">github-ffmpeg</a><br><a target="_blank" rel="noopener" href="https://embedded.blog.csdn.net/article/details/81239446">FFmpeg-命令参数</a><br><a target="_blank" rel="noopener" href="https://www.ffmpeg.org/">FFmpeg-官方文档</a><br><a target="_blank" rel="noopener" href="http://www.360doc.com/content/19/0908/03/40520079_859759183.shtml">ppi/分辨率</a><br><a target="_blank" rel="noopener" href="https://blog.csdn.net/yu540135101/article/details/103025957">FFmpeg实例集合</a></p>

                
            </div>
            <hr/>

            

    <div class="reprint" id="reprint-statement">
        
            <div class="reprint__author">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-user">
                        jiodg45:
                    </i>
                </span>
                <span class="reprint-info">
                    <a href="/jiodg45/about" rel="external nofollow noreferrer">Longxiang.guo</a>
                </span>
            </div>
            <div class="reprint__type">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-link">
                        文章链接:
                    </i>
                </span>
                <span class="reprint-info">
                    <a href="https://jiodg45.gitee.io/jiodg45/jiodg45/2021/03/11/audio-visual/ffmpeg-1/">https://jiodg45.gitee.io/jiodg45/jiodg45/2021/03/11/audio-visual/ffmpeg-1/</a>
                </span>
            </div>
            <div class="reprint__notice">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-copyright">
                        版权声明:
                    </i>
                </span>
                <span class="reprint-info">
                    本博客所有文章除特別声明外，均采用
                    <a href="https://creativecommons.org/licenses/by/4.0/deed.zh" rel="external nofollow noreferrer" target="_blank">CC BY 4.0</a>
                    许可协议。转载请注明来源
                    <a href="/jiodg45/about" target="_blank">Longxiang.guo</a>
                    !
                </span>
            </div>
        
    </div>

    <script async defer>
      document.addEventListener("copy", function (e) {
        let toastHTML = '<span>复制成功，请遵循本文的转载规则</span><button class="btn-flat toast-action" onclick="navToReprintStatement()" style="font-size: smaller">查看</a>';
        M.toast({html: toastHTML})
      });

      function navToReprintStatement() {
        $("html, body").animate({scrollTop: $("#reprint-statement").offset().top - 80}, 800);
      }
    </script>



            <div class="tag_share" style="display: block;">
                <div class="post-meta__tag-list" style="display: inline-block;">
                    
                        <div class="article-tag">
                            
                                <a href="/jiodg45/tags/audio/">
                                    <span class="chip bg-color">audio</span>
                                </a>
                            
                                <a href="/jiodg45/tags/ffmpeg/">
                                    <span class="chip bg-color">ffmpeg</span>
                                </a>
                            
                        </div>
                    
                </div>
                <div class="post_share" style="zoom: 80%; width: fit-content; display: inline-block; float: right; margin: -0.15rem 0;">
                    <link rel="stylesheet" type="text/css" href="/jiodg45/libs/share/css/share.min.css">
<div id="article-share">

    
    <div class="social-share" data-sites="twitter,facebook,google,qq,qzone,wechat,weibo,douban,linkedin" data-wechat-qrcode-helper="<p>微信扫一扫即可分享！</p>"></div>
    <script src="/jiodg45/libs/share/js/social-share.min.js"></script>
    

    

</div>

                </div>
            </div>
            
        </div>
    </div>

    

    

    

    

    

    

    

    

    

<article id="prenext-posts" class="prev-next articles">
    <div class="row article-row">
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge left-badge text-color">
                <i class="fas fa-chevron-left"></i>&nbsp;上一篇</div>
            <div class="card">
                <a href="/jiodg45/2021/03/11/ios/mov-mp4-convert/">
                    <div class="card-image">
                        
                        
                        <img src="/jiodg45/medias/featureimages/8.jpg" class="responsive-img" alt="音视频关键代码搜录">
                        
                        <span class="card-title">音视频关键代码搜录</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            iOS 音视频相关代码搜录
                        
                    </div>
                    <div class="publish-info">
                        <span class="publish-date">
                            <i class="far fa-clock fa-fw icon-date"></i>2021-03-11
                        </span>
                        <span class="publish-author">
                            
                            <i class="fas fa-bookmark fa-fw icon-category"></i>
                            
                            <a href="/jiodg45/categories/ios/" class="post-category">
                                    ios
                                </a>
                            
                            
                        </span>
                    </div>
                </div>
                
                <div class="card-action article-tags">
                    
                    <a href="/jiodg45/tags/iOS-%E8%87%AA%E5%8A%A8%E5%8C%96/">
                        <span class="chip bg-color">iOS,自动化</span>
                    </a>
                    
                </div>
                
            </div>
        </div>
        
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge right-badge text-color">
                下一篇&nbsp;<i class="fas fa-chevron-right"></i>
            </div>
            <div class="card">
                <a href="/jiodg45/2021/03/11/flutter/bloc-usage/">
                    <div class="card-image">
                        
                        
                        <img src="/jiodg45/medias/featureimages/4.jpg" class="responsive-img" alt="Flutter Bloc实战总结">
                        
                        <span class="card-title">Flutter Bloc实战总结</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            Flutter Bloc实战总结
                        
                    </div>
                    <div class="publish-info">
                            <span class="publish-date">
                                <i class="far fa-clock fa-fw icon-date"></i>2021-03-11
                            </span>
                        <span class="publish-author">
                            
                            <i class="fas fa-bookmark fa-fw icon-category"></i>
                            
                            <a href="/jiodg45/categories/flutter/" class="post-category">
                                    flutter
                                </a>
                            
                            
                        </span>
                    </div>
                </div>
                
                <div class="card-action article-tags">
                    
                    <a href="/jiodg45/tags/flutter/">
                        <span class="chip bg-color">flutter</span>
                    </a>
                    
                </div>
                
            </div>
        </div>
        
    </div>
</article>

</div>



<!-- 代码块功能依赖 -->
<script type="text/javascript" src="/jiodg45/libs/codeBlock/codeBlockFuction.js"></script>

<!-- 代码语言 -->

<script type="text/javascript" src="/jiodg45/libs/codeBlock/codeLang.js"></script>


<!-- 代码块复制 -->

<script type="text/javascript" src="/jiodg45/libs/codeBlock/codeCopy.js"></script>


<!-- 代码块收缩 -->

<script type="text/javascript" src="/jiodg45/libs/codeBlock/codeShrink.js"></script>


    </div>
    <div id="toc-aside" class="expanded col l3 hide-on-med-and-down">
        <div class="toc-widget card" style="background-color: white;">
            <div class="toc-title"><i class="far fa-list-alt"></i>&nbsp;&nbsp;目录</div>
            <div id="toc-content"></div>
        </div>
    </div>
</div>

<!-- TOC 悬浮按钮. -->

<div id="floating-toc-btn" class="hide-on-med-and-down">
    <a class="btn-floating btn-large bg-color">
        <i class="fas fa-list-ul"></i>
    </a>
</div>


<script src="/jiodg45/libs/tocbot/tocbot.min.js"></script>
<script>
    $(function () {
        tocbot.init({
            tocSelector: '#toc-content',
            contentSelector: '#articleContent',
            headingsOffset: -($(window).height() * 0.4 - 45),
            collapseDepth: Number('0'),
            headingSelector: 'h2, h3, h4'
        });

        // modify the toc link href to support Chinese.
        let i = 0;
        let tocHeading = 'toc-heading-';
        $('#toc-content a').each(function () {
            $(this).attr('href', '#' + tocHeading + (++i));
        });

        // modify the heading title id to support Chinese.
        i = 0;
        $('#articleContent').children('h2, h3, h4').each(function () {
            $(this).attr('id', tocHeading + (++i));
        });

        // Set scroll toc fixed.
        let tocHeight = parseInt($(window).height() * 0.4 - 64);
        let $tocWidget = $('.toc-widget');
        $(window).scroll(function () {
            let scroll = $(window).scrollTop();
            /* add post toc fixed. */
            if (scroll > tocHeight) {
                $tocWidget.addClass('toc-fixed');
            } else {
                $tocWidget.removeClass('toc-fixed');
            }
        });

        
        /* 修复文章卡片 div 的宽度. */
        let fixPostCardWidth = function (srcId, targetId) {
            let srcDiv = $('#' + srcId);
            if (srcDiv.length === 0) {
                return;
            }

            let w = srcDiv.width();
            if (w >= 450) {
                w = w + 21;
            } else if (w >= 350 && w < 450) {
                w = w + 18;
            } else if (w >= 300 && w < 350) {
                w = w + 16;
            } else {
                w = w + 14;
            }
            $('#' + targetId).width(w);
        };

        // 切换TOC目录展开收缩的相关操作.
        const expandedClass = 'expanded';
        let $tocAside = $('#toc-aside');
        let $mainContent = $('#main-content');
        $('#floating-toc-btn .btn-floating').click(function () {
            if ($tocAside.hasClass(expandedClass)) {
                $tocAside.removeClass(expandedClass).hide();
                $mainContent.removeClass('l9');
            } else {
                $tocAside.addClass(expandedClass).show();
                $mainContent.addClass('l9');
            }
            fixPostCardWidth('artDetail', 'prenext-posts');
        });
        
    });
</script>

    

</main>




    <footer class="page-footer bg-color">
    
        <link rel="stylesheet" href="/jiodg45/libs/aplayer/APlayer.min.css">
<style>
    .aplayer .aplayer-lrc p {
        
        display: none;
        
        font-size: 12px;
        font-weight: 700;
        line-height: 16px !important;
    }

    .aplayer .aplayer-lrc p.aplayer-lrc-current {
        
        display: none;
        
        font-size: 15px;
        color: #42b983;
    }

    
    .aplayer.aplayer-fixed.aplayer-narrow .aplayer-body {
        left: -66px !important;
    }

    .aplayer.aplayer-fixed.aplayer-narrow .aplayer-body:hover {
        left: 0px !important;
    }

    
</style>
<div class="">
    
    <div class="row">
        <meting-js class="col l8 offset-l2 m10 offset-m1 s12"
                   server="netease"
                   type="playlist"
                   id="503838841"
                   fixed='true'
                   autoplay='false'
                   theme='#42b983'
                   loop='all'
                   order='random'
                   preload='auto'
                   volume='0.7'
                   list-folded='true'
        >
        </meting-js>
    </div>
</div>

<script src="/jiodg45/libs/aplayer/APlayer.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/meting@2/dist/Meting.min.js"></script>

    
    <div class="container row center-align" style="margin-bottom: 0px !important;">
        <div class="col s12 m8 l8 copy-right">
            Copyright&nbsp;&copy;
            
                <span id="year">2019-2021</span>
            
            <span id="year">2019</span>
            <a href="/jiodg45/about" target="_blank">Longxiang.Guo</a>
            |&nbsp;Powered by&nbsp;<a href="https://hexo.io/" target="_blank">Hexo</a>
            |&nbsp;Theme&nbsp;<a href="https://github.com/blinkfox/hexo-theme-matery" target="_blank">Matery</a>
            <br>
            
            
            
            
            
            
            <span id="busuanzi_container_site_pv">
                |&nbsp;<i class="far fa-eye"></i>&nbsp;总访问量:&nbsp;<span id="busuanzi_value_site_pv"
                    class="white-color"></span>&nbsp;次
            </span>
            
            
            <span id="busuanzi_container_site_uv">
                |&nbsp;<i class="fas fa-users"></i>&nbsp;总访问人数:&nbsp;<span id="busuanzi_value_site_uv"
                    class="white-color"></span>&nbsp;人
            </span>
            
            <br>
            
            <br>
            
        </div>
        <div class="col s12 m4 l4 social-link social-statis">
    <a href="https://github.com/LongXiangGuo" class="tooltipped" target="_blank" data-tooltip="访问我的GitHub" data-position="top" data-delay="50">
        <i class="fab fa-github"></i>
    </a>



    <a href="mailto:290657563@qq.com" class="tooltipped" target="_blank" data-tooltip="邮件联系我" data-position="top" data-delay="50">
        <i class="fas fa-envelope-open"></i>
    </a>







    <a href="tencent://AddContact/?fromId=50&fromSubId=1&subcmd=all&uin=290657563" class="tooltipped" target="_blank" data-tooltip="QQ联系我: 290657563" data-position="top" data-delay="50">
        <i class="fab fa-qq"></i>
    </a>







</div>
    </div>
</footer>

<div class="progress-bar"></div>


    <!-- 搜索遮罩框 -->
<div id="searchModal" class="modal">
    <div class="modal-content">
        <div class="search-header">
            <span class="title"><i class="fas fa-search"></i>&nbsp;&nbsp;搜索</span>
            <input type="search" id="searchInput" name="s" placeholder="请输入搜索的关键字"
                   class="search-input">
        </div>
        <div id="searchResult"></div>
    </div>
</div>

<script type="text/javascript">
$(function () {
    var searchFunc = function (path, search_id, content_id) {
        'use strict';
        $.ajax({
            url: path,
            dataType: "xml",
            success: function (xmlResponse) {
                // get the contents from search data
                var datas = $("entry", xmlResponse).map(function () {
                    return {
                        title: $("title", this).text(),
                        content: $("content", this).text(),
                        url: $("url", this).text()
                    };
                }).get();
                var $input = document.getElementById(search_id);
                var $resultContent = document.getElementById(content_id);
                $input.addEventListener('input', function () {
                    var str = '<ul class=\"search-result-list\">';
                    var keywords = this.value.trim().toLowerCase().split(/[\s\-]+/);
                    $resultContent.innerHTML = "";
                    if (this.value.trim().length <= 0) {
                        return;
                    }
                    // perform local searching
                    datas.forEach(function (data) {
                        var isMatch = true;
                        var data_title = data.title.trim().toLowerCase();
                        var data_content = data.content.trim().replace(/<[^>]+>/g, "").toLowerCase();
                        var data_url = data.url;
                        data_url = data_url.indexOf('/') === 0 ? data.url : '/' + data_url;
                        var index_title = -1;
                        var index_content = -1;
                        var first_occur = -1;
                        // only match artiles with not empty titles and contents
                        if (data_title !== '' && data_content !== '') {
                            keywords.forEach(function (keyword, i) {
                                index_title = data_title.indexOf(keyword);
                                index_content = data_content.indexOf(keyword);
                                if (index_title < 0 && index_content < 0) {
                                    isMatch = false;
                                } else {
                                    if (index_content < 0) {
                                        index_content = 0;
                                    }
                                    if (i === 0) {
                                        first_occur = index_content;
                                    }
                                }
                            });
                        }
                        // show search results
                        if (isMatch) {
                            str += "<li><a href='" + data_url + "' class='search-result-title'>" + data_title + "</a>";
                            var content = data.content.trim().replace(/<[^>]+>/g, "");
                            if (first_occur >= 0) {
                                // cut out 100 characters
                                var start = first_occur - 20;
                                var end = first_occur + 80;
                                if (start < 0) {
                                    start = 0;
                                }
                                if (start === 0) {
                                    end = 100;
                                }
                                if (end > content.length) {
                                    end = content.length;
                                }
                                var match_content = content.substr(start, end);
                                // highlight all keywords
                                keywords.forEach(function (keyword) {
                                    var regS = new RegExp(keyword, "gi");
                                    match_content = match_content.replace(regS, "<em class=\"search-keyword\">" + keyword + "</em>");
                                });

                                str += "<p class=\"search-result\">" + match_content + "...</p>"
                            }
                            str += "</li>";
                        }
                    });
                    str += "</ul>";
                    $resultContent.innerHTML = str;
                });
            }
        });
    };

    searchFunc('/jiodg45/search.xml', 'searchInput', 'searchResult');
});
</script>

    <!-- 回到顶部按钮 -->
<div id="backTop" class="top-scroll">
    <a class="btn-floating btn-large waves-effect waves-light" href="#!">
        <i class="fas fa-arrow-up"></i>
    </a>
</div>


    <script src="/jiodg45/libs/materialize/materialize.min.js"></script>
    <script src="/jiodg45/libs/masonry/masonry.pkgd.min.js"></script>
    <script src="/jiodg45/libs/aos/aos.js"></script>
    <script src="/jiodg45/libs/scrollprogress/scrollProgress.min.js"></script>
    <script src="/jiodg45/libs/lightGallery/js/lightgallery-all.min.js"></script>
    <script src="/jiodg45/js/matery.js"></script>

    <!-- Baidu Analytics -->

    <!-- Baidu Push -->

<script>
    (function () {
        var bp = document.createElement('script');
        var curProtocol = window.location.protocol.split(':')[0];
        if (curProtocol === 'https') {
            bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
        } else {
            bp.src = 'http://push.zhanzhang.baidu.com/push.js';
        }
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(bp, s);
    })();
</script>

    
    <script src="/jiodg45/libs/others/clicklove.js" async="async"></script>
    
    
    <script async src="/jiodg45/libs/others/busuanzi.pure.mini.js"></script>
    

    

    

    <!--腾讯兔小巢-->
    
    

    

    

    
    <script src="/jiodg45/libs/instantpage/instantpage.js" type="module"></script>
    

</body>

</html>
